/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package data.impl;

import java.util.Date;

import data.DataFactory;
import data.DataPackage;
import data.DisplacementSample;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Displacement Sample</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link data.impl.DisplacementSampleImpl#getSpeed <em>Speed</em>}</li>
 *   <li>{@link data.impl.DisplacementSampleImpl#getHeading <em>Heading</em>}</li>
 *   <li>{@link data.impl.DisplacementSampleImpl#getDisplacement <em>Displacement</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class DisplacementSampleImpl extends DataSampleImpl implements DisplacementSample {
	/**
	 * The default value of the '{@link #getSpeed() <em>Speed</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSpeed()
	 * @generated
	 * @ordered
	 */
	protected static final float SPEED_EDEFAULT = 0.0F;

	/**
	 * The cached value of the '{@link #getSpeed() <em>Speed</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSpeed()
	 * @generated
	 * @ordered
	 */
	protected float speed = SPEED_EDEFAULT;

	/**
	 * The default value of the '{@link #getHeading() <em>Heading</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHeading()
	 * @generated
	 * @ordered
	 */
	protected static final float HEADING_EDEFAULT = 0.0F;

	/**
	 * The cached value of the '{@link #getHeading() <em>Heading</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHeading()
	 * @generated
	 * @ordered
	 */
	protected float heading = HEADING_EDEFAULT;

	/**
	 * The default value of the '{@link #getDisplacement() <em>Displacement</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDisplacement()
	 * @generated
	 * @ordered
	 */
	protected static final float DISPLACEMENT_EDEFAULT = 0.0F;

	/**
	 * The cached value of the '{@link #getDisplacement() <em>Displacement</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDisplacement()
	 * @generated
	 * @ordered
	 */
	protected float displacement = DISPLACEMENT_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected DisplacementSampleImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return DataPackage.Literals.DISPLACEMENT_SAMPLE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public float getSpeed() {
		return speed;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setSpeed(float newSpeed) {
		float oldSpeed = speed;
		speed = newSpeed;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataPackage.DISPLACEMENT_SAMPLE__SPEED, oldSpeed, speed));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public float getHeading() {
		return heading;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setHeading(float newHeading) {
		float oldHeading = heading;
		heading = newHeading;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataPackage.DISPLACEMENT_SAMPLE__HEADING, oldHeading, heading));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public float getDisplacement() {
		return displacement;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDisplacement(float newDisplacement) {
		float oldDisplacement = displacement;
		displacement = newDisplacement;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataPackage.DISPLACEMENT_SAMPLE__DISPLACEMENT, oldDisplacement, displacement));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case DataPackage.DISPLACEMENT_SAMPLE__SPEED:
				return getSpeed();
			case DataPackage.DISPLACEMENT_SAMPLE__HEADING:
				return getHeading();
			case DataPackage.DISPLACEMENT_SAMPLE__DISPLACEMENT:
				return getDisplacement();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case DataPackage.DISPLACEMENT_SAMPLE__SPEED:
				setSpeed((Float)newValue);
				return;
			case DataPackage.DISPLACEMENT_SAMPLE__HEADING:
				setHeading((Float)newValue);
				return;
			case DataPackage.DISPLACEMENT_SAMPLE__DISPLACEMENT:
				setDisplacement((Float)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case DataPackage.DISPLACEMENT_SAMPLE__SPEED:
				setSpeed(SPEED_EDEFAULT);
				return;
			case DataPackage.DISPLACEMENT_SAMPLE__HEADING:
				setHeading(HEADING_EDEFAULT);
				return;
			case DataPackage.DISPLACEMENT_SAMPLE__DISPLACEMENT:
				setDisplacement(DISPLACEMENT_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case DataPackage.DISPLACEMENT_SAMPLE__SPEED:
				return speed != SPEED_EDEFAULT;
			case DataPackage.DISPLACEMENT_SAMPLE__HEADING:
				return heading != HEADING_EDEFAULT;
			case DataPackage.DISPLACEMENT_SAMPLE__DISPLACEMENT:
				return displacement != DISPLACEMENT_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (speed: ");
		result.append(speed);
		result.append(", heading: ");
		result.append(heading);
		result.append(", displacement: ");
		result.append(displacement);
		result.append(')');
		return result.toString();
	}
	
	public boolean equalsExceptDisplacement(DisplacementSample d)
	{
		boolean result = true;
		
		if (d.getSpeed() != this.speed)
			result = false;
		else if (d.getHeading() != this.heading)
		{
			result = false;
		}

		//else if (d.getDataLogId() != this.getDataLogId())
		//{
		//	result = false;
		//}
		else if (!d.getTimestamp().equals(this.getTimestamp()))
		{
			result = false;
		}
		return(result);
	}

	public DisplacementSample clone()
	{
		DisplacementSample ds = DataFactory.eINSTANCE.createDisplacementSample();
		ds.setDisplacement(this.getDisplacement());
		ds.setHeading(this.getHeading());
		ds.setSpeed(this.getSpeed());
		ds.setTimestamp(new Date(this.getTimestamp().getTime()));
		return(ds);
	}
} //DisplacementSampleImpl
